package cheqex.dao;

import org.apache.torque.util.Criteria;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
/*
Deposit Check Peer:
addDepositCheck - adds deposit check data
editDepositCheck - edit deposit check data 
deleteDepositCheck -  delete deposit check data
*/

public class DepositCheckPeer extends cheqex.dao.BaseDepositCheckPeer
{
	public static boolean addDepositCheck(String prNumber, int amt, String particulars, java.sql.Date prDate, int id){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		criteria.add(DepositCheckPeer.AMOUNT, amt);
		criteria.add(DepositCheckPeer.PARTICULARS, particulars);
		criteria.add(DepositCheckPeer.PRDATE, prDate);
		criteria.add(DepositCheckPeer.WEEKID, id);
		try{
			DepositCheckPeer.doInsert(criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static List<DepositCheck> retrieveAllDepositCheck(java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRDATE,date);
		
		try{
			return (List<DepositCheck>)DepositCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCheck>();
		}
	}
	
	public static boolean editDepositCheck(String prNumber, int amt, String particulars,java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.AMOUNT, amt);
		criteria.add(DepositCheckPeer.PARTICULARS, particulars);
		
		Criteria scriteria = new Criteria();
		scriteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		scriteria.add(DepositCheckPeer.PRDATE, date);
		
		try{
			DepositCheckPeer.doUpdate(scriteria, criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static boolean deleteDepositCheck(String prNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		criteria.add(DepositCheckPeer.PRDATE, date);
		try{
			DepositCheckPeer.doDelete(criteria);
			return true;
		}catch (Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public static DepositCheck getPR(String prNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		criteria.add(DepositCheckPeer.PRDATE, date);
		try{
			if((DepositCheck)DepositCheckPeer.doSelect(criteria).get(0)!=null)
				return (DepositCheck)DepositCheckPeer.doSelect(criteria).get(0);
			else return null;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	public static List<DepositCheck> getData(String prNumber){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		
		try{
			return (List<DepositCheck>)DepositCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	public static List<DepositCheck> filterDepositCheckByPRNo(String prNumber){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		
		try{
			return (List<DepositCheck>)DepositCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCheck>();
		}
	}
	
	public static List<DepositCheck> filterDepositCheckByPRDate(java.sql.Date prDate){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRDATE, prDate);
		
		try{
			return (List<DepositCheck>)DepositCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCheck>();
		}
	}
	
	public static List<DepositCheck> searchDepositCheckParticular(String prNumber, java.sql.Date prDate){
		Criteria criteria = new Criteria();
		criteria.add(DepositCheckPeer.PRNUMBER, prNumber);
		criteria.add(DepositCheckPeer.PRDATE, prDate);
		
		try{
			return (List<DepositCheck>)DepositCheckPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCheck>();
		}
	}

}
